import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:meiyunapp/generated/assets.dart';
import 'package:meiyunapp/router/routers_pages.dart';

class SplashPage extends StatefulWidget {
  const SplashPage({Key? key}) : super(key: key);

  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  late Timer _timer;

  @override
  void initState() {
    super.initState();

    _timer = Timer.periodic(const Duration(seconds: 3), (timer) {
      timer.cancel();
      Get.offNamed(RouterPath.page_login);
    });
  }

  @override
  void dispose() {
    _timer.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(
      context,
      designSize: const Size(375, 690),
    );
    return Scaffold(
      body: Column(
        children: const [
          Expanded(
            flex: 3,
            child: Image(
              width: double.infinity,
              fit: BoxFit.fill,
              image: AssetImage(Assets.imageIcSplash),
            ),
          ),
          Expanded(
            child: Image(
              width: 185,
              height: 121,
              image: AssetImage(Assets.imageIcSplashLogo),
            ),
          )
        ],
      ),
    );
  }
}
